Now let's go through some of the common mistakes
and understand the best practices to be followed while
performing the exercise. Before you do that, please remember the
following points. Node.js is event-based and very well suited
for microservices. HTTP is a first-class
citizen in Node.js, designed with streaming
and low latency in mind. It makes Node.js well-suited for the foundation of a web
library or framework. Node.js is also suitable
for decoupled applications, as you can use lots of NPM modules to set up
a great microservice. Node.js is fast and its event-based nature
makes it a great choice, even for real-time applications. Applications and
microservices locate each other on the network
using service discovery. The API Gateway is considered an entry point to the
microservices world. API Gateway provide
a shared layer to handle differences between service protocols and fulfill the requirements of
specific clients, such as desktop browsers, mobile devices, and
legacy systems. The API Gateway can route
requests, transform protocols, aggregate data, and implement shared logics such as
authentication and rate limiters. The following are some of the common mistakes made while
performing the exercise. Not adding dependencies. Add all the required
dependencies while implementing code. Using references
before creating them. Create and initialize all the references
before using them. Not following a proper
microservice architecture, implement a proper
communication channel, discovery service,
and API Gateway. Using an incorrect Uniform
Resource Identifier or URI. Use the correct URI of
microservices and databases. Not following the
test case guidelines. All the functionalities
are to be tested through a test case. While avoiding common mistakes, note some of the
best practices to follow while performing
the exercise. Use HTTP methods and API routes. Use HTTP status codes correctly. Use HTTP headers
to send metadata. Pick the right framework for
your Node.js microservice. Use conditional requests. Organize the files
around features. Don't put logic in
index.js files, and place your test files
next to the implementation.